//
//  CC_Maintabar.swift
//  swift_weibo
//
//  Created by ccl on 16/2/18.
//  Copyright © 2016年 LittleBoy. All rights reserved.
//

import UIKit

class CC_Maintabar: UITabBar {

    private let subVCCount = 5
    
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        let btnW = bounds.width / CGFloat(subVCCount)
        let frame = CGRectMake(0, 0, btnW, bounds.height)
         var index  = 0
        
        for v in subviews{
            if v is UIControl {
            v.frame = CGRectOffset(frame, btnW * CGFloat(index), 0)
            
                index += index == 1 ? 2 : 1
            }
            compoesButton.frame = CGRectOffset(frame, btnW * 2, 0)
            //print("-----\(v)")
        }
        
    }
    
    lazy var compoesButton :UIButton = {
      
        let btn = UIButton(type: UIButtonType.Custom)
        btn.setBackgroundImage(UIImage(named: "tabbar_compose_button"), forState:UIControlState.Normal)
        btn.setBackgroundImage(UIImage(named: "tabbar_compose_button_highlighted"), forState: UIControlState.Selected)
        btn.setImage(UIImage(named: "tabbar_compose_icon_add"), forState:UIControlState.Normal)
        btn.setImage(UIImage(named: "tabbar_compose_icon_add_highlighted"), forState:UIControlState.Normal)
        self.addSubview(btn)
  
        return btn
    
    }()

}
